WPS Office.apk(点击下载) / suf.java


package defpackage;

import com.mopub.common.Constants;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.eclipse.paho.client.mqttv3.internal.security.SSLSocketFactoryFactory;

/* renamed from: suf  reason: default package */
public final class suf {
    public static final HostnameVerifier ouv = new HostnameVerifier() {
        /* class defpackage.suf.AnonymousClass1 */

        public final boolean verify(String str, SSLSession sSLSession) {
            return true;
        }
    };
    private static List<String> utF = new ArrayList();

    private static InputStream b(URL url, HashMap<String, String> hashMap, int i) throws IOException {
        HttpURLConnection httpURLConnection;
        if (url.getProtocol().toLowerCase().equals(Constants.HTTPS)) {
            TrustManager[] trustManagerArr = {new X509TrustManager() {
                /* class defpackage.suf.AnonymousClass2 */

                @Override // javax.net.ssl.X509TrustManager
                public final void checkClientTrusted(X509Certificate[] x509CertificateArr, String str) throws CertificateException {
                }

                @Override // javax.net.ssl.X509TrustManager
                public final void checkServerTrusted(X509Certificate[] x509CertificateArr, String str) throws CertificateException {
                }

                public final X509Certificate[] getAcceptedIssuers() {
                    return new X509Certificate[0];
                }
            }};
            try {
                SSLContext instance = SSLContext.getInstance(SSLSocketFactoryFactory.DEFAULT_PROTOCOL);
                instance.init(null, trustManagerArr, new SecureRandom());
                HttpsURLConnection.setDefaultSSLSocketFactory(instance.getSocketFactory());
            } catch (Exception e) {
                e.printStackTrace();
            }
            httpURLConnection = (HttpsURLConnection) url.openConnection();
            ((HttpsURLConnection) httpURLConnection).setHostnameVerifier(ouv);
        } else {
            httpURLConnection = (HttpURLConnection) url.openConnection();
        }
        httpURLConnection.setDoInput(true);
        httpURLConnection.setRequestMethod("GET");
        httpURLConnection.setConnectTimeout(15000);
        httpURLConnection.setReadTimeout(15000);
        try {
            return httpURLConnection.getInputStream();
        } catch (AssertionError e2) {
            throw new IOException(e2.getMessage());
        }
    }

    public static List<String> fgT() {
        if (utF.size() == 0) {
            try {
                fgU();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        ArrayList arrayList = new ArrayList();
        for (String str : utF) {
            arrayList.add(str);
        }
        return arrayList;
    }

    public static void fgU() throws IOException {
        String z = z(b(new URL("https://img1.cache.qwps.cn/account/iplist.json"), null, 15000));
        if (!sug.isEmpty(z)) {
            try {
                sup sup = new sup(z);
                if (sup.has("ips")) {
                    for (String str : sud.SO(sup.ST("ips").toString())) {
                        utF.add(str);
                    }
                    if (sup.has("proxy_ips")) {
                        for (String str2 : sud.SO(sup.ST("proxy_ips").toString())) {
                            utF.add(str2);
                        }
                    }
                }
            } catch (suo e) {
                e.printStackTrace();
            }
        }
    }

    private static String z(InputStream inputStream) {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        StringBuilder sb = new StringBuilder();
        while (true) {
            try {
                String readLine = bufferedReader.readLine();
                if (readLine != null) {
                    sb.append(readLine);
                } else {
                    try {
                        break;
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            } catch (IOException e2) {
                e2.printStackTrace();
                try {
                    bufferedReader.close();
                    inputStream.close();
                } catch (IOException e3) {
                    e3.printStackTrace();
                }
            } catch (Throwable th) {
                try {
                    bufferedReader.close();
                    inputStream.close();
                } catch (IOException e4) {
                    e4.printStackTrace();
                }
                throw th;
            }
        }
        bufferedReader.close();
        inputStream.close();
        return sb.toString();
    }
}